//package com.ymatou.paymentproxy.testcase;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import org.junit.After;
//import org.junit.AfterClass;
//import org.junit.Before;
//import org.junit.BeforeClass;
//import org.junit.Test;
//import org.junit.experimental.categories.Category;
//
//import com.ymatou.paymentproxy.parameter.AcquireOrderBean;
//import com.ymatou.paymentproxy.parameter.ApproveRefundBean;
//import com.ymatou.paymentproxy.service.ApproveRefundCall;
//import com.ymt.core.tool.Logger;
//import com.ymt.utils.annotation.TestCase;
//import com.ymt.utils.annotation.TestSuite;
//import com.ymt.utils.tag.P3;
//import com.ymttest.business.service.PayGateWayCallService;
//import com.ymttest.database.model.RefundRequest;
//import com.ymttest.database.sqlwapper.PaymentDefaultWapper;
//
///**
// * 退款申请审核通过接口
// * FreeMaker Template自动生成代码
// */
//@TestSuite
//public class Ts_ApproveRefund {
//    private static ApproveRefundBean approverefundBean;
//    private static ApproveRefundCall approverefundCall;
//
//    @BeforeClass
//    public static void setUp() {
//        Logger.createResultFile("退款申请审核通过接口");
//    }
//
//    @Before
//    public void caseUp() {
//        approverefundBean = new ApproveRefundBean();
//        approverefundCall = new ApproveRefundCall();
//    }
//
//    @AfterClass
//    public static void tearDown() {
//        Logger.generateResult(approverefundCall.getOpurl());
//    }
//
//    @After
//    public void caseDown() {
//        Logger.end();
//    }
//
//    @Test
//    @Category({P3.class})
//    @TestCase
//    public void Tc_ApproveRefund_001() {
//        Logger.start(true, "审核退款成功");
//        try {
//            AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
//            PayGateWayCallService.acquireOrder(aqb);
//            PayGateWayCallService.notifyCall(aqb);
//            PayGateWayCallService.submitRefund(aqb);
//            String pid = PayGateWayCallService.getPaymentId(aqb);
//            approverefundBean.setApproveUser("AutoTest");
//            List<String> PaymentIds = new ArrayList<String>();
//            PaymentIds.add(pid);
//            approverefundBean.setPaymentIds(PaymentIds);
//
//            approverefundCall.setData(approverefundBean);
//            approverefundCall.callService();
//
//            Logger.verifyEquals(true, approverefundCall.getOkflag(), "验证okFlag");
//            verifyDB(approverefundBean);
//
//        } catch (Exception e) {
//            Logger.fail(e);
//        }
//    }
//
//    @Test
//    @Category({P3.class})
//    @TestCase
//    public void Tc_ApproveRefund_002() {
//        Logger.start(true, "不输入PaymentIds审核退款失败");
//        try {
//            // AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
//            // PayGateWayCallService.acquireOrder(aqb);
//            // PayGateWayCallService.notifyCall(aqb);
//            // PayGateWayCallService.submitRefund(aqb);
//            // String pid = PayGateWayCallService.getPaymentId(aqb);
//            approverefundBean.setApproveUser("AutoTest");
//            // List<String> PaymentIds=new ArrayList<String>();
//            // PaymentIds.add(pid);
//            // approverefundBean.setPaymentIds(PaymentIds);
//            approverefundCall.setData(approverefundBean);
//            approverefundCall.callService();
//            Logger.verifyEquals("-9999", approverefundCall.getString("ErrorCode"), "验证ErrorCode");
////            Logger.verifyEquals("null", approverefundCall.getString("ErrorMessage"), "验证ErrorMessage");
//        } catch (Exception e) {
//            Logger.fail(e);
//        }
//    }
//
//    @Test
//    @Category({P3.class})
//    @TestCase
//    public void Tc_ApproveRefund_003() {
//        Logger.start(true, "不输入ApproveUses审核退款失败");
//        try {
//            AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
//            PayGateWayCallService.acquireOrder(aqb);
//            PayGateWayCallService.notifyCall(aqb);
//            PayGateWayCallService.submitRefund(aqb);
//            String pid = PayGateWayCallService.getPaymentId(aqb);
//            // approverefundBean.setApproveUser("AutoTest");
//            List<String> PaymentIds = new ArrayList<String>();
//            PaymentIds.add(pid);
//            approverefundBean.setPaymentIds(PaymentIds);
//            approverefundCall.setData(approverefundBean);
//            approverefundCall.callService();
//            // ??
//            Logger.verifyEquals(true, approverefundCall.getOkflag(), "验证okFlag");
//        } catch (Exception e) {
//            Logger.fail(e);
//        }
//    }
//
//    @Test
//    @Category({P3.class})
//    @TestCase
//    public void Tc_ApproveRefund_004() {
//        Logger.start(true, "输入不存在PaymentIds审核退款失败");
//        try {
//            String pid = "000000";
//            approverefundBean.setApproveUser("AutoTest");
//            List<String> PaymentIds = new ArrayList<String>();
//            PaymentIds.add(pid);
//            approverefundBean.setPaymentIds(PaymentIds);
//            approverefundCall.setData(approverefundBean);
//            approverefundCall.callService();
//            Logger.verifyEquals("-9999", approverefundCall.getString("ErrorCode"), "验证ErrorCode");
//            Logger.verifyIsContains("error message refund request not exist",
//                    approverefundCall.getString("ErrorMessage"), "验证ErrorMessage");
//        } catch (Exception e) {
//            Logger.fail(e);
//        }
//    }
//
//    @Test
//    @Category({P3.class})
//    @TestCase
//    public void Tc_ApproveRefund_005() {
//        Logger.start(true, "PaymentIds传入空列表审核退款失败");
//        try {
//            // AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
//            // PayGateWayCallService.acquireOrder(aqb);
//            // PayGateWayCallService.notifyCall(aqb);
//            // PayGateWayCallService.submitRefund(aqb);
//            // String pid = PayGateWayCallService.getPaymentId(aqb);
//            approverefundBean.setApproveUser("AutoTest");
//            List<String> PaymentIds = new ArrayList<String>();
//            // PaymentIds.add(pid);
//            approverefundBean.setPaymentIds(PaymentIds);
//            approverefundCall.setData(approverefundBean);
//            approverefundCall.callService();
//            Logger.verifyEquals("0", approverefundCall.getString("ErrorCode"), "验证ErrorCode");
//            Logger.verifyEquals("null", approverefundCall.getString("ErrorMessage"), "验证ErrorMessage");
//        } catch (Exception e) {
//            Logger.fail(e);
//        }
//    }
//
//    @Test
//    @Category({P3.class})
//    @TestCase
//    public void Tc_ApproveRefund_006() {
//        Logger.start(true, "审核多笔退款成功");
//        try {
//            AcquireOrderBean aqb1 = PayGateWayCallService.initAcquireOrder("10");
//
//            PayGateWayCallService.acquireOrder(aqb1);
//            PayGateWayCallService.notifyCall(aqb1);
//            PayGateWayCallService.submitRefund(aqb1);
//            String pid1 = PayGateWayCallService.getPaymentId(aqb1);
//
//            AcquireOrderBean aqb2 = PayGateWayCallService.initAcquireOrder("10");
//
//            PayGateWayCallService.acquireOrder(aqb2);
//            PayGateWayCallService.notifyCall(aqb2);
//            PayGateWayCallService.submitRefund(aqb2);
//            String pid2 = PayGateWayCallService.getPaymentId(aqb2);
//
//            approverefundBean.setApproveUser("AutoTest");
//            List<String> PaymentIds = new ArrayList<String>();
//            PaymentIds.add(pid1);
//            PaymentIds.add(pid2);
//            approverefundBean.setPaymentIds(PaymentIds);
//
//            approverefundCall.setData(approverefundBean);
//            approverefundCall.callService();
//
//            Logger.verifyEquals(true, approverefundCall.getOkflag(), "验证okFlag");
//            verifyDB(approverefundBean);
//
//        } catch (Exception e) {
//            Logger.fail(e);
//        }
//    }
//
//    private void verifyDB(ApproveRefundBean approverefundBean) throws Exception {
//        Logger.comment("验证数据库RefundRequest");
//
//        List<String> paymentIdsList = approverefundBean.getPaymentIds();
//
//        for (int i = 0; i < paymentIdsList.size(); i++) {
//            RefundRequest RefundRequest =
//                    new PaymentDefaultWapper().selectRefundRequestByPaymentid(paymentIdsList.get(i)).get(0);
//            Logger.verifyEquals(1, RefundRequest.getApproveStatus(), "验证RefundRequest表中ApproveStatus字段与返回一致");
//        }
//    }
//}
